﻿@model WebSoftSeo.Models.Blog
@{
    ViewBag.Title = "CreateBlogArticle";
    Layout = "~/Views/Shared/_LayoutSubscribe.cshtml";
}
<script src="~/nicEditor/nicEdit.js"></script>
<script>
    bkLib.onDomLoaded(function () {
        new nicEditor({ fullPanel: true, uploadURI: '/@WebSoftSeo.Models.GlobalVariables.PathFolderName/Home/nicUpload' }).panelInstance('area');

    });
    bkLib.onDomLoaded(function () {
        new nicEditor({ fullPanel: true, uploadURI: '/@WebSoftSeo.Models.GlobalVariables.PathFolderName/Home/nicUpload' }).panelInstance('area1');

    });
    bkLib.onDomLoaded(function () {
        new nicEditor({ fullPanel: true, uploadURI: '/@WebSoftSeo.Models.GlobalVariables.PathFolderName/Home/nicUpload' }).panelInstance('area2');

    });
</script>

 <!-- form Blog -->
        <div class="wrapForm">
        	<div class="container">
                @using (Html.BeginForm("Create", "Blog", FormMethod.Post, new {enctype= "multipart/form-data",id="BlogCreate" }))
                {
                <div class="formContact" style="margin-top:15px">
                    <ul>
                        <li>
                            <label>Tiêu đề</label>
                            <div class="testboxC">
                                @*<input type="text" placeholder="Tiêu đề" class="validation-failed">*@
                                @Html.TextBoxFor(m => m.Title, new {id="TitleBlog" })
                                <p id="TitleBlogE" class="required"></p>
                                <div class="clearfix"></div>
                            </div>
                        </li>
                        <li>
                            <label>Thể loại</label>
                            <div class="testboxC">
                                @*<input type="text" placeholder="Tiêu đề" class="validation-failed">*@
                                @if (ViewBag.blogcategory != null)
                                {
                                @Html.DropDownList("CategoriesID", ViewBag.blogcategory as SelectList, "-- Chọn thể loại --", new { id="BlogCategory" })
                                }
                                <p id="BlogCategoryE" class="required"></p>
                                @*<p class="required">Vui lòng nhập tên</p>*@
                                <div class="clearfix"></div>
                            </div>
                        </li>
                        <li>

                            <label>Tóm tắt</label>
                            <div class="testboxC">
                               
                                @Html.TextAreaFor(m => m.ShortDescription)
                                <div class="clearfix"></div>
                            </div>
                        </li>
                        <li>
                            <label>Hình đại diện</label>
                            <div class="testboxC">
                                <input type="file" name="img1">
                                <div class="clearfix"></div>
                            </div>
                        </li>
                        <li>
                            <label>Nội dung</label>
                            <div class="testboxC">
                                @Html.TextAreaFor(m => m.Contents, new { id = "area", @class="BlogContent" })
                              @*  <textarea></textarea>*@
                                <p id="BlogContentE" class="required"></p>
                                <div class="clearfix"></div>
                            </div>
                        </li>
                    </ul>
                    <button type="submit" class="button">Đăng</button>
                </div>
                }
            	<div class="clearfix"></div>
            </div>
        </div>
        <!-- End form blog -->

<script type="text/javascript">

    function ValidateBlog() {
        var TitleBlog = $("#TitleBlog").val();
        var BlogCategory = $("#BlogCategory").val();
        var BlogContent = $(".BlogContent").val();
       
        if (TitleBlog == "" || BlogCategory == "" || BlogCategory==null || BlogContent == "" || BlogContent == "<br>") {
            if (BlogContent == "") {
                $("#BlogContentE").html("Vui lòng nhập nội dung");
                $("#area").addClass("validation-failed");
                $("#area").focus();
            }
            if (BlogCategory == "" || BlogCategory==null) {
                $("#BlogCategoryE").html("Vui lòng chọn thể loại");
                $("#BlogCategory").addClass("validation-failed");
                $("#BlogCategory").focus();
            }
            if (TitleBlog == "") {
                $("#TitleBlogE").html("Vui lòng nhập tiêu đề");
                $("#TitleBlog").addClass("validation-failed");
                $("#TitleBlog").focus();

            }
           
            return false;
        }
       

        return true;
    }



</script>
<script type="text/javascript">
    $("#TitleBlog").blur(function () {
        var TitleBlog = $('#TitleBlog').val();
        if (TitleBlog != "") {
            document.getElementById("TitleBlogE").innerHTML = "";
            $("#TitleBlog").removeClass("validation-failed")
        }
    });
</script>
<script type="text/javascript">
    $("#BlogCategory").blur(function () {
        var BlogCategory = $('#BlogCategory').val();
        if (BlogCategory != "") {
            document.getElementById("BlogCategoryE").innerHTML = "";
            $("#BlogCategory").removeClass("validation-failed")
        }
    });
</script>
<script type="text/javascript">
    $("#area").blur(function () {
        var area = $('#area').val();
        if (area != "") {
            document.getElementById("BlogContentE").innerHTML = "";
            $("#area").removeClass("validation-failed")
        }
    });
</script>

<script type="text/javascript">
    $('#BlogCreate').submit(function () {

        return ValidateBlog();

    });
</script>
